package com.example.onlinemusic.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.onlinemusic.common.R;
import com.example.onlinemusic.mapper.CollectMapper;
import com.example.onlinemusic.model.domain.Collect;
import com.example.onlinemusic.service.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 收藏的接口实现类
 */
@Service
public class CollectServiceImpl extends ServiceImpl<CollectMapper, Collect> implements CollectService {
    @Autowired
    CollectMapper collectMapper;

    @Override
    public R collectOfUser(int userId) {
        // TODO 根据userId查询该用户的收藏信息
        // 步骤：
        // 1.使用QueryWrapper设置查询条件
        QueryWrapper<Collect> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",userId);
        // 2.调用mybatis提供的查询列表方法
        List<Collect> collects = collectMapper.selectList(queryWrapper);
        return R.success("查询成功",collects);
    }
}
